classdef Synapse < handle
    
    properties (GetAccess = public, SetAccess = public)
        % all parameters
        Parameters
        % neuron that received the charge
        PostSynapticNeuron
        
        CurrentGapLatency
        CurrentGapValue
        
        SynapseStrength
    end
    
    methods
        
        % synapse activation function. 
        % This function should be called by a neuron
        function Activate(obj, value)
            obj.CurrentGapLatency = obj.Parameters.GapLatency;
            obj.CurrentGapValue = value;
        end
        
        function Update(obj)            
            
            if obj.CurrentGapLatency == 1
                obj.PostSynapticNeuron.Charge(obj.CurrentGapValue * obj.SynapseStrength);
            end
            
            if obj.CurrentGapLatency > 0
                obj.CurrentGapLatency = obj.CurrentGapLatency - 1;
            end            
            
        end
        
        % function called by PostSynaptic neuron when activated 
        % (for synapse plasticity)
        function NotifyPostSynapticNeuronActivation(obj)
            
            
            
        end
        
        % constructor
        function ret = Synapse(parameters, postSynapticNeuron)
            ret.Parameters = parameters;
            ret.PostSynapticNeuron = postSynapticNeuron;
        end
        
    end
    
end

